package com.syswin.lhztest.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

/**
 * 初始化或者刷新时执行
 * 观察者模式 发布订阅、消息通知机制、事件监听、事件驱动编程
 *
 * @author:lhz
 * @date:2018/11/14 15:28
 */
@Service
public class FreshListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        //防止启动两次
//      if(event.getApplicationContext().getParent() !=null) {
            System.out.println("-----------ContextRefreshedEvent启动---------");
//        }
    }
}
